﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;

// “用户控件”项模板在 http://go.microsoft.com/fwlink/?LinkId=234236 上提供

namespace Studio77.FruitLinkLink2.Views
{
    public sealed partial class LinkCard : UserControl
    {
        public LinkCard()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// 行号
        /// </summary>
        public int X { get; set; }

        /// <summary>
        /// 列号
        /// </summary>
        public int Y { get; set; }

        /// <summary>
        /// 区分不同的块
        /// </summary>
        public int Value { get; set; }

        /// <summary>
        /// 设置选中状态
        /// </summary>
        public void SetSelectedCard()
        {
            this.bdrSelect.Visibility = Windows.UI.Xaml.Visibility.Visible;
            this.ItemStoryBroad.RepeatBehavior = RepeatBehavior.Forever;
            this.ItemStoryBroad.Begin();
        }

        /// <summary>
        /// 设置成未选中状态
        /// </summary>
        public void SetUnSelectedCard()
        {
            this.ItemStoryBroad.Stop();
            this.bdrSelect.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }

        /// <summary>
        /// 设置成寻找状态
        /// </summary>
        public void SetFind()
        {
            this.bdrFind.Visibility = Windows.UI.Xaml.Visibility.Visible;
            this.bdrSelect.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            this.ItemStoryBroad.RepeatBehavior = RepeatBehavior.Forever;
            this.ItemStoryBroad.Begin();
        }

        public void SetValue(int value)
        {
            string uri = @" ms-appx:///Image/item" + value.ToString() + ".jpg";
            BitmapImage bitmap = new BitmapImage(new Uri(uri));
            this.gameImage.Source = bitmap;
            Value = value;
        }
    }
}
